/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.LogFactory;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Server;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class RemoveAccountLogger
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 45 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/* 47 */     Server localServer = Provisioning.getInstance().getLocalServer();
/* 48 */     checkRight(zsc, context, localServer, Rights.Admin.R_manageAccountLogger);
/*    */     
/*    */ 
/* 51 */     Account account = null;
/* 52 */     String accountName = null;
/* 53 */     if ((request.getOptionalElement("id") != null) || (request.getOptionalElement("account") != null))
/*    */     {
/* 55 */       account = AddAccountLogger.getAccountFromLoggerRequest(request);
/* 56 */       accountName = account.getName();
/*    */     }
/*    */     
/*    */ 
/* 60 */     Element eLogger = request.getOptionalElement("logger");
/* 61 */     String category = null;
/* 62 */     if (eLogger != null) {
/* 63 */       category = eLogger.getAttribute("category");
/* 64 */       if (category.equalsIgnoreCase(AddAccountLogger.CATEGORY_ALL)) {
/* 65 */         category = null;
/* 66 */       } else if (!LogFactory.logExists(category)) {
/* 67 */         throw ServiceException.INVALID_REQUEST("Log category " + category + " does not exist.", null);
/*    */       }
/*    */     }
/*    */     
/*    */ 
/* 72 */     for (Log log : LogFactory.getAllLoggers()) {
/* 73 */       if ((category == null) || (log.getCategory().equals(category))) {
/* 74 */         if (accountName != null) {
/* 75 */           boolean removed = log.removeAccountLogger(accountName);
/* 76 */           if (removed) {
/* 77 */             ZimbraLog.misc.info("Removed logger for account %s from category %s.", new Object[] { accountName, log.getCategory() });
/*    */           }
/*    */         }
/*    */         else {
/* 81 */           int count = log.removeAccountLoggers();
/* 82 */           if (count > 0) {
/* 83 */             ZimbraLog.misc.info("Removed %d custom loggers from category %s.", new Object[] { Integer.valueOf(count), log.getCategory() });
/*    */           }
/*    */         }
/*    */       }
/*    */     }
/*    */     
/*    */ 
/*    */ 
/* 91 */     Element response = zsc.createElement(AdminConstants.REMOVE_ACCOUNT_LOGGER_RESPONSE);
/* 92 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 97 */     relatedRights.add(Rights.Admin.R_manageAccountLogger);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/RemoveAccountLogger.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */